﻿/*
 ***************************************************************************
 * Microsoft Visual C# .NET
 * 名称：       App_Input_PhysicalRegisteForm
 * 类型：       体检报告登记画面
 * 功能说明：   体检报告登记
 * 作者：       谈震鸣
 * 创建日期：   2007/08/27
 * 修改日期     修改者      修改内容
 * 
 * 
 * ---
 ***************************************************************************
*/
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Shpm.App.Input.Bean;
using Shpm.App.Input.Dao;
using Shpm.App.Commons.Db.Beans.Master;
using Shpm.App.Master.Dao;
using Shpm.App.Commons.Utils;
using Shpm.System;

public partial class App_Input_PhysicalRegisteForm : System.Web.UI.Page
{


    #region 常量
    public const string CMB_NUTRITION = "T_PHYSICAL.NUTRITION";
    public const string CMB_COLORFEEL = "T_PHYSICAL.COLORFEEL";
    public const string CMB_SMELLFEEL = "T_PHYSICAL.SMELLFEEL";
    public const string CMB_TRACHOMALEFT = "T_PHYSICAL.TRACHOMALEFT";
    public const string CMB_TRACHOMARIGHT = "T_PHYSICAL.TRACHOMARIGHT ";
    public const string CMB_TONSIL = "T_PHYSICAL.TONSIL";
    public const string CMB_PARAPET = "T_PHYSICAL.PARAPET";
    public const string CMB_JOINT = "T_PHYSICAL.JOINT";
    public const string CMB_HAEMORRHOIDS = "T_PHYSICAL.HAEMORRHOIDS";
    public const string CMB_SPINALCOLUMN = "T_PHYSICAL.SPINALCOLUMN";
    public const string CMB_FLATFOOT = "T_PHYSICAL.FLATFOOT";
    public const string CMB_LIMB = "T_PHYSICAL.LIMB";
    public const string CMB_VARICOSITYBEND = "T_PHYSICAL.VARICOSITYBEND";
    public const string CMB_VARICOSITYSPREAD = "T_PHYSICAL.VARICOSITYSPREAD";
    public const string CMB_LYMPH = "T_PHYSICAL.LYMPH";
    public const string CMB_REFLECT = "T_PHYSICAL.REFLECT";
    public const string CMB_COLIC = "T_PHYSICAL.COLIC";
    public const string CMB_HEARTRANGE = "T_PHYSICAL.HEARTRANGE";
    public const string CMB_HEARTSOUNDS = "T_PHYSICAL.HEARTSOUNDS";
    public const string CMB_THYROIDGLAND = "T_PHYSICAL.THYROIDGLAND";
    public const string CMB_LUNG = "T_PHYSICAL.LUNG";
    public const string CMB_SPIRITBEND = "T_PHYSICAL.SPIRITBEND";
    public const string CMB_PAUNCH = "T_PHYSICAL.PAUNCH";
    #endregion

    #region Page_Load
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack == false)
        {
           // if (Context.Items["LST_LOAD"]!=null) ViewState["LST_LOAD"] = (bool)Context.Items["LST_LOAD"];
            
            ViewState["TXT_PERSONID"] = (string)Context.Items["TXT_PERSONID"];
            ViewState["TXT_NAME"] = (string)Context.Items["TXT_NAME"];
            ViewState["TXT_DATE"] = (string)Context.Items["TXT_DATE"];
            ViewState["TXT_END_DATE"] = (string)Context.Items["TXT_END_DATE"];
            SetCmb();
            if ((string)Context.Items["PHYSICAL_ID"] != string.Empty && (string)Context.Items["PHYSICAL_ID"] != null)
            {
                bool Flg = true;
                ViewState["UPDATE"] = Flg;
                this.ViewState["PHYSICAL_ID"] = (string)Context.Items["PHYSICAL_ID"];
                btnDel.Enabled =true ;
                //读取数据
                PhyscalBean dataBean = new PhyscalBean();
                dataBean.PhysicalId = int.Parse((string)this.ViewState["PHYSICAL_ID"]);
                PhyscalDao Dao = new PhyscalDao();
                SetData(Dao.Load(dataBean));
                
            }
            else if ((string)Context.Items["PERSON_ID"] != string.Empty && (string)Context.Items["PERSON_ID"] != null)
            {
                bool Flg = false;
                ViewState["UPDATE"] = Flg;
                this.ViewState["PERSON_ID"] = (string)Context.Items["PERSON_ID"];
                btnDel.Enabled = false;
                PhyscalBean dataBean = new PhyscalBean();
                PhyscalDao Dao = new PhyscalDao();
                dataBean.PersonId = int.Parse((string)this.ViewState["PERSON_ID"]);
                SetPersonInfo(Dao.PersonLoad(dataBean));
            }

        }
        if (Context.Items.Contains("PersonParamPageIndex"))
        {
            this.ViewState["PersonParamPageIndex"] = Convert.ToString(Context.Items["PersonParamPageIndex"]);
        }
        if (Context.Items.Contains("ParamPageIndex"))
        {
            this.ViewState["ParamPageIndex"] = Convert.ToString(Context.Items["ParamPageIndex"]);
        }
    }
    #endregion

    #region 设置下拉框
    /*
    *名称： SetCmb
    *功能： 设置下拉框
    *参数： 无
    *返回： 无
    *说明： 无
    */
    private void SetCmb()
    {
        SetCmbNutrition();
        SetCmbColorFeel();
        SetCmbSmellFeel();
        SetCmbTrachomaLeft();
        SetCmbTrachomaRight();
        SetCmbTonsil();
        SetCmbParapet();
        SetCmbJoint();
        SetCmbHaemorrhoids();
        SetCmbSpinalColumn();
        SetCmbFlatfoot();
        SetCmbLimb();
        SetCmbVaricosityBend();
        SetCmbVaricositySpread();
        SetCmbLymph();
        SetCmbReflect();
        SetCmbColic();
        SetCmbHeartRange();
        SetCmbHeartSounds();
        SetCmbThyroidGland();
        SetCmbLung();
        SetCmbSpiritBend();
        SetCmbPaunch();
    }

    //营养
    private void SetCmbNutrition()
    {
        CommonDictionaryBean paramBean = new CommonDictionaryBean();
        paramBean.Catalog = CMB_NUTRITION;
        CommonDictionaryDao dao = new CommonDictionaryDao();
        IList dataList = dao.FindByCatalog(paramBean);
        cmbNutrition.DataSource = dataList;
        cmbNutrition.DataBind();
        if (SetCmbIndex(dataList) != -1)
            cmbNutrition.SelectedIndex = SetCmbIndex(dataList);
    }
    //色觉
    private void SetCmbColorFeel()
    {
        CommonDictionaryBean paramBean = new CommonDictionaryBean();
        paramBean.Catalog = CMB_COLORFEEL;
        CommonDictionaryDao dao = new CommonDictionaryDao();
        IList dataList = dao.FindByCatalog(paramBean);
        cmbColorFeel.DataSource = dataList;
        cmbColorFeel.DataBind();
        if (SetCmbIndex(dataList) != -1)
            cmbColorFeel.SelectedIndex = SetCmbIndex(dataList);
    }
    //嗅觉
    private void SetCmbSmellFeel()
    {
        CommonDictionaryBean paramBean = new CommonDictionaryBean();
        paramBean.Catalog = CMB_SMELLFEEL;
        CommonDictionaryDao dao = new CommonDictionaryDao();
        IList dataList = dao.FindByCatalog(paramBean);
        cmbSmellFeel.DataSource = dataList;
        cmbSmellFeel.DataBind();
        if (SetCmbIndex(dataList) != -1)
            cmbSmellFeel.SelectedIndex = SetCmbIndex(dataList);
    }
    //沙眼左
    private void SetCmbTrachomaLeft()
    {
        CommonDictionaryBean paramBean = new CommonDictionaryBean();
        paramBean.Catalog = CMB_TRACHOMALEFT;
        CommonDictionaryDao dao = new CommonDictionaryDao();
        IList dataList = dao.FindByCatalog(paramBean);
        cmbTrachomaLeft.DataSource = dataList;
        cmbTrachomaLeft.DataBind();
        if (SetCmbIndex(dataList) != -1)
            cmbTrachomaLeft.SelectedIndex = SetCmbIndex(dataList);
    }
    //沙眼右
    private void SetCmbTrachomaRight()
    {
        CommonDictionaryBean paramBean = new CommonDictionaryBean();
        paramBean.Catalog = CMB_TRACHOMARIGHT;
        CommonDictionaryDao dao = new CommonDictionaryDao();
        IList dataList = dao.FindByCatalog(paramBean);
        cmbTrachomaRight.DataSource = dataList;
        cmbTrachomaRight.DataBind();
        if (SetCmbIndex(dataList) != -1)
            cmbTrachomaRight.SelectedIndex = SetCmbIndex(dataList);
    }
    //扁桃体
    private void SetCmbTonsil()
    {
        CommonDictionaryBean paramBean = new CommonDictionaryBean();
        paramBean.Catalog = CMB_TONSIL;
        CommonDictionaryDao dao = new CommonDictionaryDao();
        IList dataList = dao.FindByCatalog(paramBean);
        cmbTonsil.DataSource = dataList;
        cmbTonsil.DataBind();
        if (SetCmbIndex(dataList) != -1)
            cmbTonsil.SelectedIndex = SetCmbIndex(dataList);
    }
    //胸廓
    private void SetCmbParapet()
    {
        CommonDictionaryBean paramBean = new CommonDictionaryBean();
        paramBean.Catalog = CMB_PARAPET;
        CommonDictionaryDao dao = new CommonDictionaryDao();
        IList dataList = dao.FindByCatalog(paramBean);
        cmbParapet.DataSource = dataList;
        cmbParapet.DataBind();
        if (SetCmbIndex(dataList) != -1)
            cmbParapet.SelectedIndex = SetCmbIndex(dataList);
    }
    //关节
    private void SetCmbJoint()
    {
        CommonDictionaryBean paramBean = new CommonDictionaryBean();
        paramBean.Catalog = CMB_JOINT;
        CommonDictionaryDao dao = new CommonDictionaryDao();
        IList dataList = dao.FindByCatalog(paramBean);
        cmbJoint.DataSource = dataList;
        cmbJoint.DataBind();
        if (SetCmbIndex(dataList) != -1)
            cmbJoint.SelectedIndex = SetCmbIndex(dataList);
    }
    //痔核
    private void SetCmbHaemorrhoids()
    {
        CommonDictionaryBean paramBean = new CommonDictionaryBean();
        paramBean.Catalog = CMB_HAEMORRHOIDS;
        CommonDictionaryDao dao = new CommonDictionaryDao();
        IList dataList = dao.FindByCatalog(paramBean);
        cmbHaemorrhoids.DataSource = dataList;
        cmbHaemorrhoids.DataBind();
        if (SetCmbIndex(dataList) != -1)
            cmbHaemorrhoids.SelectedIndex = SetCmbIndex(dataList);
    }
    //脊柱
    private void SetCmbSpinalColumn()
    {
        CommonDictionaryBean paramBean = new CommonDictionaryBean();
        paramBean.Catalog = CMB_SPINALCOLUMN;
        CommonDictionaryDao dao = new CommonDictionaryDao();
        IList dataList = dao.FindByCatalog(paramBean);
        cmbSpinalColumn.DataSource = dataList;
        cmbSpinalColumn.DataBind();
        if (SetCmbIndex(dataList) != -1)
            cmbSpinalColumn.SelectedIndex = SetCmbIndex(dataList);
    }
    //平底足
    private void SetCmbFlatfoot()
    {
        CommonDictionaryBean paramBean = new CommonDictionaryBean();
        paramBean.Catalog = CMB_FLATFOOT;
        CommonDictionaryDao dao = new CommonDictionaryDao();
        IList dataList = dao.FindByCatalog(paramBean);
        cmbFlatfoot.DataSource = dataList;
        cmbFlatfoot.DataBind();
        if (SetCmbIndex(dataList) != -1)
            cmbFlatfoot.SelectedIndex = SetCmbIndex(dataList);
    }
    //四肢
    private void SetCmbLimb()
    {
        CommonDictionaryBean paramBean = new CommonDictionaryBean();
        paramBean.Catalog = CMB_LIMB;
        CommonDictionaryDao dao = new CommonDictionaryDao();
        IList dataList = dao.FindByCatalog(paramBean);
        cmbLimb.DataSource = dataList;
        cmbLimb.DataBind();
        if (SetCmbIndex(dataList) != -1)
            cmbLimb.SelectedIndex = SetCmbIndex(dataList);
    }
    //静脉曲
    private void SetCmbVaricosityBend()
    {
        CommonDictionaryBean paramBean = new CommonDictionaryBean();
        paramBean.Catalog = CMB_VARICOSITYBEND;
        CommonDictionaryDao dao = new CommonDictionaryDao();
        IList dataList = dao.FindByCatalog(paramBean);
        cmbVaricosityBend.DataSource = dataList;
        cmbVaricosityBend.DataBind();
        if (SetCmbIndex(dataList) != -1)
            cmbVaricosityBend.SelectedIndex = SetCmbIndex(dataList);
    }
    //静脉张
    private void SetCmbVaricositySpread()
    {
        CommonDictionaryBean paramBean = new CommonDictionaryBean();
        paramBean.Catalog = CMB_VARICOSITYSPREAD;
        CommonDictionaryDao dao = new CommonDictionaryDao();
        IList dataList = dao.FindByCatalog(paramBean);
        cmbVaricositySpread.DataSource = dataList;
        cmbVaricositySpread.DataBind();
        if (SetCmbIndex(dataList) != -1)
            cmbVaricositySpread.SelectedIndex = SetCmbIndex(dataList);
    }
    //淋巴腺
    private void SetCmbLymph()
    {
        CommonDictionaryBean paramBean = new CommonDictionaryBean();
        paramBean.Catalog = CMB_LYMPH;
        CommonDictionaryDao dao = new CommonDictionaryDao();
        IList dataList = dao.FindByCatalog(paramBean);
        cmbLymph.DataSource = dataList;
        cmbLymph.DataBind();
        if (SetCmbIndex(dataList) != -1)
            cmbLymph.SelectedIndex = SetCmbIndex(dataList);
    }
    //反射
    private void SetCmbReflect()
    {
        CommonDictionaryBean paramBean = new CommonDictionaryBean();
        paramBean.Catalog = CMB_LYMPH;
        CommonDictionaryDao dao = new CommonDictionaryDao();
        IList dataList = dao.FindByCatalog(paramBean);
        cmbReflect.DataSource = dataList;
        cmbReflect.DataBind();
        if (SetCmbIndex(dataList) != -1)
            cmbReflect.SelectedIndex = SetCmbIndex(dataList);
    }
    //疝气
    private void SetCmbColic()
    {
        CommonDictionaryBean paramBean = new CommonDictionaryBean();
        paramBean.Catalog = CMB_COLIC;
        CommonDictionaryDao dao = new CommonDictionaryDao();
        IList dataList = dao.FindByCatalog(paramBean);
        cmbColic.DataSource = dataList;
        cmbColic.DataBind();
        if (SetCmbIndex(dataList) != -1)
            cmbColic.SelectedIndex = SetCmbIndex(dataList);
    }
    //心界
    private void SetCmbHeartRange()
    {
        CommonDictionaryBean paramBean = new CommonDictionaryBean();
        paramBean.Catalog = CMB_HEARTRANGE;
        CommonDictionaryDao dao = new CommonDictionaryDao();
        IList dataList = dao.FindByCatalog(paramBean);
        cmbHeartRange.DataSource = dataList;
        cmbHeartRange.DataBind();
        if (SetCmbIndex(dataList) != -1)
            cmbHeartRange.SelectedIndex = SetCmbIndex(dataList);
    }
    //心音
    private void SetCmbHeartSounds()
    {
        CommonDictionaryBean paramBean = new CommonDictionaryBean();
        paramBean.Catalog = CMB_HEARTSOUNDS;
        CommonDictionaryDao dao = new CommonDictionaryDao();
        IList dataList = dao.FindByCatalog(paramBean);
        cmbHeartSounds.DataSource = dataList;
        cmbHeartSounds.DataBind();
        if (SetCmbIndex(dataList) != -1)
            cmbHeartSounds.SelectedIndex = SetCmbIndex(dataList);
    }
    //甲状腺
    private void SetCmbThyroidGland()
    {
        CommonDictionaryBean paramBean = new CommonDictionaryBean();
        paramBean.Catalog = CMB_THYROIDGLAND;
        CommonDictionaryDao dao = new CommonDictionaryDao();
        IList dataList = dao.FindByCatalog(paramBean);
        cmbThyroidGland.DataSource = dataList;
        cmbThyroidGland.DataBind();
        if (SetCmbIndex(dataList) != -1)
            cmbThyroidGland.SelectedIndex = SetCmbIndex(dataList);
    }
    //肺
    private void SetCmbLung()
    {
        CommonDictionaryBean paramBean = new CommonDictionaryBean();
        paramBean.Catalog = CMB_LUNG;
        CommonDictionaryDao dao = new CommonDictionaryDao();
        IList dataList = dao.FindByCatalog(paramBean);
        cmbLung.DataSource = dataList;
        cmbLung.DataBind();
        if (SetCmbIndex(dataList) != -1)
            cmbLung.SelectedIndex = SetCmbIndex(dataList);
    }
    //精神压缩
    private void SetCmbSpiritBend()
    {
        CommonDictionaryBean paramBean = new CommonDictionaryBean();
        paramBean.Catalog = CMB_SPIRITBEND;
        CommonDictionaryDao dao = new CommonDictionaryDao();
        IList dataList = dao.FindByCatalog(paramBean);
        cmbSpiritBend.DataSource = dataList;
        cmbSpiritBend.DataBind();
        if (SetCmbIndex(dataList) != -1)
            cmbSpiritBend.SelectedIndex = SetCmbIndex(dataList);
    }
    //腹
    private void SetCmbPaunch()
    {
        CommonDictionaryBean paramBean = new CommonDictionaryBean();
        paramBean.Catalog = CMB_PAUNCH;
        CommonDictionaryDao dao = new CommonDictionaryDao();
        IList dataList = dao.FindByCatalog(paramBean);
        cmbPaunch.DataSource = dataList;
        cmbPaunch.DataBind();
        if (SetCmbIndex(dataList) != -1)
            cmbPaunch.SelectedIndex = SetCmbIndex(dataList);
    }
    //设置下拉框的默认值
    private int SetCmbIndex(IList list)
    {
        CommonDictionaryBean dataBean = new CommonDictionaryBean();
        for (int i = 0; i < list.Count; i++)
        {
            dataBean = (CommonDictionaryBean)list[i];
            if (dataBean.Default == true) return i;
        }
        return -1;
    }
    #endregion

    #region 登录按钮
    /*
    *名称： btnAdd_Click
    *功能： 登录按钮
    *参数： 无
    *返回： 无
    *说明： 无
    */
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        if (ComValidator1.DoValidator())
        {
            PhyscalDao Dao = new PhyscalDao();
            if (ViewState["UPDATE"] != null && (bool)ViewState["UPDATE"])
            {
                Dao.UpdatePhyscal(SetBean((bool)ViewState["UPDATE"]));
                PhyscalBean dataBean = new PhyscalBean();
                dataBean.PhysicalId = int.Parse((string)ViewState["PHYSICAL_ID"]);
                SetData(Dao.Load(dataBean));
                ((Design_MasterPage)this.Master).InfoMessage = "更新成功！";
            }
            else if(!(bool)ViewState["UPDATE"])
            {
                int i =(int)Dao.InsertPhyscal(SetBean((bool)ViewState["UPDATE"]));
                PhyscalBean dataBean = new PhyscalBean();
                dataBean.PhysicalId = i;
                SetData(Dao.Load(dataBean));
                ((Design_MasterPage)this.Master).InfoMessage = "登录成功！";
            }
        }
    }
    #endregion

    #region 显示数据
    //显示数据
    private void SetData(PhyscalBean dataBean)
    {
        if (dataBean != null)
        {
            ViewState["PERSON_ID"] = dataBean.PersonId.ToString();
            personID.Text = dataBean.PersonId.ToString();
            nameC.Text = dataBean.Name;
            sex.Text = GetDocData("SEX", dataBean.Sex.ToString());
            nationality.Text = GetDocData("M_PERSON.NATIONALITY", dataBean.Nationality);
            native.Text = GetDocData("M_PERSON.NATIVE", dataBean.Native);
            if (dataBean.Birthday != null) birthday.Text = (DateUtils.convertToString(dataBean.Birthday.Value)).Replace("-", "/");
            addressHome.Text = dataBean.AddressHome;
            if (dataBean.AdjustEyesightL > 0) txtAdjustEyesightL.Text = dataBean.AdjustEyesightL.ToString();
            if (dataBean.AdjustEyesightR > 0) txtAdjustEyesightR.Text = dataBean.AdjustEyesightR.ToString();
            if (dataBean.Age > 0) txtAge.Text = dataBean.Age.ToString();
            if (dataBean.AnalFistula != null) txtAnalFistula.Text = dataBean.AnalFistula.ToString();
            if (dataBean.BloodPressureBend > 0) txtBloodPressureBend.Text = dataBean.BloodPressureBend.ToString();
            if (dataBean.BloodPressureSpread > 0) txtBloodSressureSpread.Text = dataBean.BloodPressureSpread.ToString();
            if (dataBean.ChestBreath > 0) txtChestBreath.Text = dataBean.ChestBreath.ToString();
            if (dataBean.ChestSniff > 0) txtChestSniff.Text = dataBean.ChestSniff.ToString();
            if (dataBean.EyesightL > 0) txtEyesightL.Text = dataBean.EyesightL.ToString();
            if (dataBean.EyesightR > 0) txtEyesightR.Text = dataBean.EyesightR.ToString();
            if (dataBean.FamilyMedicalRecord != null) txtFamilyMedicalRecord.Text = dataBean.FamilyMedicalRecord.ToString();
            if (dataBean.Fistula != null) txtFistula.Text = dataBean.Fistula.ToString();
            if (dataBean.GripLeft > 0) txtGripLeft.Text = dataBean.GripLeft.ToString();
            if (dataBean.GripRight > 0) txtGripRight.Text = dataBean.GripRight.ToString();
            if (dataBean.HearingLeft > 0) txtHearingLeft.Text = dataBean.HearingLeft.ToString();
            if (dataBean.HearingRight > 0) txtHearingRight.Text = dataBean.HearingRight.ToString();
            if (dataBean.Height > 0) txtHeight.Text = dataBean.Height.ToString();
            if (dataBean.Liver != null) txtLiver.Text = dataBean.Liver.ToString();
            if (dataBean.Malformation != null) txtMalformation.Text = dataBean.Malformation.ToString();
            if (dataBean.Nose != null) txtNose.Text = dataBean.Nose.ToString();
            if (dataBean.OtherEye != null) txtOtherEye.Text = dataBean.OtherEye.ToString();
            if (dataBean.OtherFiveOrgans != null) txtOtherFiveOrgans.Text = dataBean.OtherFiveOrgans.ToString();
            if (dataBean.OtherInternalMedicine != null) txtOtherInternalMedicine.Text = dataBean.OtherInternalMedicine.ToString();
            if (dataBean.OtherSurgery != null) txtOtherSurgery.Text = dataBean.OtherSurgery.ToString();
            if (dataBean.PersonMedicalRecord != null) txtPersonMedicalRecord.Text = dataBean.PersonMedicalRecord.ToString();
            if (dataBean.Pudendum != null) txtPudendum.Text = dataBean.Pudendum.ToString();
            if (dataBean.Pulse > 0) txtPulse.Text = dataBean.Pulse.ToString();
            if (dataBean.Skin != null) txtSkin.Text = dataBean.Skin.ToString();
            if (dataBean.Spleen != null) txtSpleen.Text = dataBean.Spleen.ToString();
            if (dataBean.Teeth != null) txtTeeth.Text = dataBean.Teeth.ToString();
            if (dataBean.Throat != null) txtThroat.Text = dataBean.Throat.ToString();
            if (dataBean.Weight > 0) txtWeight.Text = dataBean.Weight.ToString();

            cmbColic.SelectedValue = dataBean.Colic;
            cmbColorFeel.SelectedValue = dataBean.ColorFeel;
            cmbFlatfoot.SelectedValue = dataBean.Flatfoot;
            cmbHaemorrhoids.SelectedValue = dataBean.Haemorrhoids;
            cmbHeartRange.SelectedValue = dataBean.HeartRange;
            cmbHeartSounds.SelectedValue = dataBean.HeartSounds;
            cmbJoint.SelectedValue = dataBean.Joint;
            cmbLimb.SelectedValue = dataBean.Limb;
            cmbLung.SelectedValue = dataBean.Lung;
            cmbLymph.SelectedValue = dataBean.Lymph;
            cmbNutrition.SelectedValue = dataBean.Nutrition;
            cmbParapet.SelectedValue = dataBean.Parapet;
            cmbPaunch.SelectedValue = dataBean.Paunch;
            cmbReflect.SelectedValue = dataBean.Reflect;
            cmbSmellFeel.SelectedValue = dataBean.SmellFeel;
            cmbSpinalColumn.SelectedValue = dataBean.SpinalColumn;
            cmbSpiritBend.SelectedValue = dataBean.SpiritBend;
            cmbThyroidGland.SelectedValue = dataBean.ThyroidGland;
            cmbTonsil.SelectedValue = dataBean.Tonsil;
            cmbTrachomaLeft.SelectedValue = dataBean.TrachomaLeft;
            cmbTrachomaRight.SelectedValue = dataBean.TrachomaRight;
            cmbVaricosityBend.SelectedValue = dataBean.VaricosityBend;
            cmbVaricositySpread.SelectedValue = dataBean.VaricositySpread;
        }
    }
    #endregion

    #region 取得数据字典的内容
    //取得数据字典的内容
    private string GetDocData(string str1, string str2)
    {
        CommonDictionaryBean dataBean = new CommonDictionaryBean();
        CommonDictionaryDao Dao = new CommonDictionaryDao();
        dataBean.Catalog = str1;
        dataBean.DictNo = str2;
        dataBean = Dao.Load(dataBean);
        if (dataBean != null && dataBean.Content != null) return dataBean.Content;
        else return string.Empty;
    }
    #endregion

    #region 将数据传入Bean
    //将数据传入Bean
    private PhyscalBean SetBean(bool flg)
    {
        PhyscalBean dataBean = new PhyscalBean();
        if (flg) dataBean.PhysicalId = int.Parse((string)ViewState["PHYSICAL_ID"]);
        if (!flg) dataBean.PersonId = int.Parse((string)ViewState["PERSON_ID"]);
        if (txtAdjustEyesightL.Text != string.Empty) dataBean.AdjustEyesightL = decimal.Parse(txtAdjustEyesightL.Text);
        if (txtAdjustEyesightR.Text != string.Empty) dataBean.AdjustEyesightR = decimal.Parse(txtAdjustEyesightR.Text);
        if (txtAge.Text != string.Empty) dataBean.Age = int.Parse(txtAge.Text);
        if (txtAnalFistula.Text != string.Empty) dataBean.AnalFistula = txtAnalFistula.Text;
        if (txtBloodPressureBend.Text != string.Empty) dataBean.BloodPressureBend = int.Parse(txtBloodPressureBend.Text);
        if (txtBloodSressureSpread.Text != string.Empty) dataBean.BloodPressureSpread = int.Parse(txtBloodSressureSpread.Text);
        if (txtChestBreath.Text != string.Empty) dataBean.ChestBreath = int.Parse(txtChestBreath.Text);
        if (txtChestSniff.Text != string.Empty) dataBean.ChestSniff = int.Parse(txtChestSniff.Text);
        if (txtEyesightL.Text != string.Empty) dataBean.EyesightL = decimal.Parse(txtEyesightL.Text);
        if (txtEyesightR.Text != string.Empty) dataBean.EyesightR = decimal.Parse(txtEyesightR.Text);
        if (txtFamilyMedicalRecord.Text != string.Empty) dataBean.FamilyMedicalRecord = txtFamilyMedicalRecord.Text;
        if (txtFistula.Text != string.Empty) dataBean.Fistula = txtFistula.Text;
        if (txtGripLeft.Text != string.Empty) dataBean.GripLeft = decimal.Parse(txtGripLeft.Text);
        if (txtGripRight.Text != string.Empty) dataBean.GripRight = decimal.Parse(txtGripRight.Text);
        if (txtHearingLeft.Text != string.Empty) dataBean.HearingLeft = decimal.Parse(txtHearingLeft.Text);
        if (txtHearingRight.Text != string.Empty) dataBean.HearingRight = decimal.Parse(txtHearingRight.Text);
        if (txtHeight.Text != string.Empty) dataBean.Height = int.Parse(txtHeight.Text);
        if (txtLiver.Text != string.Empty) dataBean.Liver = txtLiver.Text;
        if (txtMalformation.Text != string.Empty) dataBean.Malformation = txtMalformation.Text;
        if (txtNose.Text != string.Empty) dataBean.Nose = txtNose.Text;
        if (txtOtherEye.Text != string.Empty) dataBean.OtherEye = txtOtherEye.Text;
        if (txtOtherFiveOrgans.Text != string.Empty) dataBean.OtherFiveOrgans = txtOtherFiveOrgans.Text;
        if (txtOtherInternalMedicine.Text != string.Empty) dataBean.OtherInternalMedicine = txtOtherInternalMedicine.Text;
        if (txtOtherSurgery.Text != string.Empty) dataBean.OtherSurgery = txtOtherSurgery.Text;
        if (txtPersonMedicalRecord.Text != string.Empty) dataBean.PersonMedicalRecord = txtPersonMedicalRecord.Text;
        if (txtPudendum.Text != string.Empty) dataBean.Pudendum = txtPudendum.Text;
        if (txtPulse.Text != string.Empty) dataBean.Pulse = int.Parse(txtPulse.Text);
        if (txtSkin.Text != string.Empty) dataBean.Skin = txtSkin.Text;
        if (txtSpleen.Text != string.Empty) dataBean.Spleen = txtSpleen.Text;
        if (txtTeeth.Text != string.Empty) dataBean.Teeth = txtTeeth.Text;
        if (txtThroat.Text != string.Empty) dataBean.Throat = txtThroat.Text;
        if (txtWeight.Text != string.Empty) dataBean.Weight = int.Parse(txtWeight.Text);
        dataBean.Colic = cmbColic.SelectedValue;
        dataBean.ColorFeel = cmbColorFeel.SelectedValue;
        dataBean.Flatfoot = cmbFlatfoot.SelectedValue;
        dataBean.Haemorrhoids = cmbHaemorrhoids.SelectedValue;
        dataBean.HeartRange = cmbHeartRange.SelectedValue;
        dataBean.HeartSounds = cmbHeartSounds.SelectedValue;
        dataBean.Joint = cmbJoint.SelectedValue;
        dataBean.Limb = cmbLimb.SelectedValue;
        dataBean.Lung = cmbLung.SelectedValue;
        dataBean.Lymph = cmbLymph.SelectedValue;
        dataBean.Nutrition = cmbNutrition.SelectedValue;
        dataBean.Parapet = cmbParapet.SelectedValue;
        dataBean.Paunch = cmbPaunch.SelectedValue;
        dataBean.Reflect = cmbReflect.SelectedValue;
        dataBean.SmellFeel = cmbSmellFeel.SelectedValue;
        dataBean.SpinalColumn = cmbSpinalColumn.SelectedValue;
        dataBean.SpiritBend = cmbSpiritBend.SelectedValue;
        dataBean.ThyroidGland = cmbThyroidGland.SelectedValue;
        dataBean.Tonsil = cmbTonsil.SelectedValue;
        dataBean.TrachomaLeft = cmbTrachomaLeft.SelectedValue;
        dataBean.TrachomaRight = cmbTrachomaRight.SelectedValue;
        dataBean.VaricosityBend = cmbVaricosityBend.SelectedValue;
        dataBean.VaricositySpread = cmbVaricositySpread.SelectedValue;
        //userID
        SysUserManager manager = new SysUserManager(Context);
        SysUserBean sysUserBean = manager.getSysUserBean();
        MstSysUserBean mstSysUserBean = sysUserBean.getMstSysUserBean();
        dataBean.UserId = mstSysUserBean.SysUserId;
        //dataBean.UserId = "tan";
        return dataBean;
    }
    #endregion

    #region 设置个人信息
    private void SetPersonInfo(PhyscalBean dataBean)
    {
        if (dataBean != null)
        {
            personID.Text = dataBean.PersonId.ToString();
            nameC.Text = dataBean.Name;
            sex.Text = GetDocData("SEX", dataBean.Sex.ToString());
            nationality.Text = GetDocData("M_PERSON.NATIONALITY", dataBean.Nationality);
            native.Text = GetDocData("M_PERSON.NATIVE", dataBean.Native);


            if (dataBean.Birthday != null) birthday.Text = (DateUtils.convertToString(dataBean.Birthday.Value)).Replace("-", "/");
            addressHome.Text = dataBean.AddressHome;
        }
    }
    #endregion

    #region 全部清空
    private void AllClear()
    {
        txtAdjustEyesightL.Text = string.Empty ;
        txtAdjustEyesightR.Text = string.Empty;
        txtAge.Text = string.Empty;
        txtAnalFistula.Text = string.Empty;
        txtBloodPressureBend.Text = string.Empty;
        txtBloodSressureSpread.Text = string.Empty;
        txtChestBreath.Text = string.Empty;
        txtChestSniff.Text = string.Empty;
        txtEyesightL.Text = string.Empty;
        txtEyesightR.Text = string.Empty;
        txtFamilyMedicalRecord.Text = string.Empty;
        txtFistula.Text = string.Empty;
        txtGripLeft.Text = string.Empty;
        txtGripRight.Text = string.Empty;
        txtHearingLeft.Text = string.Empty;
        txtHearingRight.Text = string.Empty;
        txtHeight.Text = string.Empty;
        txtLiver.Text = string.Empty;
        txtMalformation.Text = string.Empty;
        txtNose.Text = string.Empty;
        txtOtherEye.Text = string.Empty;
        txtOtherFiveOrgans.Text = string.Empty;
        txtOtherInternalMedicine.Text = string.Empty;
        txtOtherSurgery.Text = string.Empty;
        txtPersonMedicalRecord.Text = string.Empty;
        txtPudendum.Text = string.Empty;
        txtPulse.Text = string.Empty;
        txtSkin.Text = string.Empty;
        txtSpleen.Text = string.Empty;
        txtTeeth.Text = string.Empty;
        txtThroat.Text = string.Empty;
        txtWeight.Text = string.Empty;
        SetCmb();
    }
    #endregion

    #region 取消输入按钮
    protected void btnCancel_Click(object sender, EventArgs e)
    {
        AllClear();
        PhyscalBean dataBean = new PhyscalBean();
        PhyscalDao Dao = new PhyscalDao();
        dataBean.PersonId = int.Parse((string)ViewState["PERSON_ID"]);
        SetPersonInfo(Dao.PersonLoad(dataBean));
    }
    #endregion

    #region 删除按钮
    protected void btnDel_Click(object sender, EventArgs e)
    {
        PhyscalBean dataBean = new PhyscalBean();
        PhyscalDao Dao = new PhyscalDao();
        dataBean.PhysicalId = int.Parse((string)ViewState["PHYSICAL_ID"]);
        if ((Dao.FindBySalesProc(dataBean)).Count>0 )
        {
            ((Design_MasterPage)this.Master).InfoMessage = "该表已经被其他程序占用，不能删除！";
            dataBean.PhysicalId = int.Parse((string)ViewState["PHYSICAL_ID"]);
            SetData(Dao.Load(dataBean));
        }
        else
        {
            dataBean.PhysicalId = int.Parse((string)ViewState["PHYSICAL_ID"]);
            Dao.DeletePhyscal(dataBean);
            ((Design_MasterPage)this.Master).InfoMessage = "删除成功！";
            AllClear();
        }
        
        
    }
    #endregion

    #region 返回按钮
    //返回按钮
    protected void btnBack_Click(object sender, EventArgs e)
    {
        if ((bool)ViewState["UPDATE"])
        {

            //Context.Items["LST_LOAD"] = ViewState["LST_LOAD"];
            Context.Items["TXT_PERSONID"] = Convert.ToString(this.ViewState["TXT_PERSONID"]);
            Context.Items["TXT_NAME"] = Convert.ToString(this.ViewState["TXT_NAME"]);
            Context.Items["TXT_DATE"] = Convert.ToString(this.ViewState["TXT_DATE"]);
            Context.Items["TXT_END_DATE"] = Convert.ToString(this.ViewState["TXT_END_DATE"]);
            Context.Items["PERSON_ID"] = Convert.ToString(this.ViewState["PERSON_ID"]);
            Context.Items["PersonParamPageIndex"] = Convert.ToString(this.ViewState["PersonParamPageIndex"]);
            Context.Items["ParamPageIndex"] = Convert.ToString(this.ViewState["ParamPageIndex"]);
            // Server.Transfer("PhysicalSearchForm.aspx");
            ControllerUtils.Transfer(this.Context, "~/App/Input/PhysicalPersonSearchForm.aspx");
            
        }
        else
        {
            Context.Items["TXT_PERSONID"] = Convert.ToString(this.ViewState["TXT_PERSONID"]);
            Context.Items["TXT_NAME"] = Convert.ToString(this.ViewState["TXT_NAME"]);
            Context.Items["TXT_DATE"] = Convert.ToString(this.ViewState["TXT_DATE"]);
            Context.Items["TXT_END_DATE"] = Convert.ToString(this.ViewState["TXT_END_DATE"]);
            Context.Items["PERSON_ID"] = ViewState["PERSON_ID"];
            // Server.Transfer("PhysicalUpdateForm.aspx");
            ControllerUtils.Transfer(this.Context, "~/App/Input/PhysicalUpdateForm.aspx");
        }
    }
    #endregion
}

